www.gusucode.com > 超声波测量以及形成图像 对相关信号进行模拟仿真 > 超声波测量以及形成图像 对相关信号进行模拟仿真/digital holograpy/dh/ddfilter_window.m
function varargout = ddfilter_window(varargin) % DDFILTER_WINDOW M-file for ddfilter_window.fig % DDFILTER_WINDOW, by itself, creates a new DDFILTER_WINDOW or raises the existing % singleton*. % % H = DDFILTER_WINDOW returns the handle to a new DDFILTER_WINDOW or the handle to % the existing singleton*. % % DDFILTER_WINDOW('CALLBACK',hObject,eventData,handles,...) calls the local % function named CALLBACK in DDFILTER_WINDOW.M with the given input arguments. % % DDFILTER_WINDOW('Property','Value',...) creates a new DDFILTER_WINDOW or raises the % existing singleton*. Starting from the left, property value pairs are % applied to the GUI before ddfilter_window_OpeningFunction gets called. An % unrecognized property name or invalid value makes property application % stop. All inputs are passed to ddfilter_window_OpeningFcn via varargin. % % *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one % instance to run (singleton)". % % See also: GUIDE, GUIDATA, GUIHANDLES % Edit the above text to modify the response to help ddfilter_window % Last Modified by GUIDE v2.5 26-Aug-2007 16:43:24 % Begin initialization code - DO NOT EDIT gui_Singleton = 1; gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @ddfilter_window_OpeningFcn, ... 'gui_OutputFcn', @ddfilter_window_OutputFcn, ... 'gui_LayoutFcn', [] , ... 'gui_Callback', []); if nargin & isstr(varargin{1}) gui_State.gui_Callback = str2func(varargin{1}); end if nargout [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); else gui_mainfcn(gui_State, varargin{:}); end % End initialization code - DO NOT EDIT % --- Executes just before ddfilter_window is made visible. function ddfilter_window_OpeningFcn(hObject, eventdata, handles, varargin) % This function has no output args, see OutputFcn. % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % varargin command line arguments to ddfilter_window (see VARARGIN) set(handles.lbox,'String',cell(1,0),'value',1); axes(handles.prev_axes) imagesc(ones(256)),colormap(gray); %axis equal tight; handles.us=2; handles.phase=[]; if nargin > 4 for n=1:2:length(varargin) if strcmpi(varargin{n},'phasemaps') handles.phase=varargin{n+1}; if ~isempty(handles.phase) set(handles.lbox,'string',sort(fieldnames(handles.phase))) end end end end % Choose default command line output for ddfilter_window handles.output = hObject; % Update handles structure guidata(hObject, handles); % UIWAIT makes ddfilter_window wait for user response (see UIRESUME) uiwait(handles.ddfilter_window); % --- Outputs from this function are returned to the command line. function varargout = ddfilter_window_OutputFcn(hObject, eventdata, handles) % varargout cell array for returning output args (see VARARGOUT); % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Get default command line output from handles structure if isempty(findobj('type','figure','tag','ddfilter_window')) varargout{1}=[]; return end if strcmp(get(handles.done_button,'enable'),'off') varargout{1}=handles.phase; else varargout{1}=[]; end delete(handles.ddfilter_window) % --- Executes during object creation, after setting all properties. function lbox_CreateFcn(hObject, eventdata, handles) % hObject handle to lbox (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: listbox controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc set(hObject,'BackgroundColor','white'); else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); end % --- Executes on selection change in lbox. function lbox_Callback(hObject, eventdata, handles) % hObject handle to lbox (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: contents = get(hObject,'String') returns lbox contents as cell array % contents{get(hObject,'Value')} returns selected item from lbox if strcmp(get(handles.ddfilter_window,'SelectionType'),'open') prev_button_Callback(handles.prev_button, [], handles); end % --- Executes during object creation, after setting all properties. function us_edit_CreateFcn(hObject, eventdata, handles) % hObject handle to us_edit (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc set(hObject,'BackgroundColor','white'); else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); end function us_edit_Callback(hObject, eventdata, handles) % hObject handle to us_edit (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of us_edit as text % str2double(get(hObject,'String')) returns contents of us_edit as a double handles.us=round(abs(str2num(get(hObject,'string')))); if isempty(handles.us) || length(handles.us)>1 || handles.us==0 handles.us=1; end set(hObject,'string',num2str(handles.us)); guidata(hObject,handles) % --- Executes on button press in selected_radio. function selected_radio_Callback(hObject, eventdata, handles) % hObject handle to selected_radio (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hint: get(hObject,'Value') returns toggle state of selected_radio if get(handles.all_radio,'value')==get(handles.all_radio,'max') set(hObject,'value',get(hObject,'max')) set(handles.all_radio,'value',get(handles.all_radio,'min')) else set(hObject,'value',get(hObject,'max')) end % --- Executes on button press in all_radio. function all_radio_Callback(hObject, eventdata, handles) % hObject handle to all_radio (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hint: get(hObject,'Value') returns toggle state of all_radio if get(handles.selected_radio,'value')==get(handles.selected_radio,'max') set(hObject,'value',get(hObject,'max')) set(handles.selected_radio,'value',get(handles.selected_radio,'min')) else set(hObject,'value',get(hObject,'max')) end % --- Executes on button press in done_button. function done_button_Callback(hObject, eventdata, handles) % hObject handle to done_button (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) if isequal(get(handles.ddfilter_window, 'waitstatus'), 'waiting') % The GUI is still in UIWAIT, us UIRESUME set(hObject,'enable','off') uiresume(handles.ddfilter_window); else % The GUI is no longer waiting, just close it delete(handles.ddfilter_window); end % --- Executes when user attempts to close ddfilter_window. function ddfilter_window_CloseRequestFcn(hObject, eventdata, handles) % hObject handle to ddfilter_window (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hint: delete(hObject) closes the figure if isequal(get(handles.ddfilter_window, 'waitstatus'), 'waiting') % The GUI is still in UIWAIT, us UIRESUME uiresume(handles.ddfilter_window); else % The GUI is no longer waiting, just close it delete(handles.ddfilter_window); end % --- Executes on button press in prev_button. function prev_button_Callback(hObject, eventdata, handles) % hObject handle to prev_button (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) items=get(handles.lbox,'string'); index=get(handles.lbox,'value'); if isempty(items) || length(index)>1 return end axes(handles.prev_axes) [vx,vy]=opticimage(handles.phase(2).(items{index}).MN2,handles.phase(2).(items{index}).dxy2(1),... handles.phase(2).(items{index}).dxy2(2),handles.phase(2).(items{index}).center); imagesc(vx,vy,handles.phase(1).(items{index}),[-pi,pi]);colormap(gray);axis xy image; % --- Executes on button press in filter_button. function filter_button_Callback(hObject, eventdata, handles) % hObject handle to filter_button (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) items=get(handles.lbox,'string'); if isempty(items) || handles.us==1 return end if get(handles.selected_radio,'value')==get(handles.selected_radio,'max') index=get(handles.lbox,'value'); items=items(index); end for n=1:length(items) [handles.phase(1).(items{n}),handles.phase(3).(items{n}).weight]=... PMC(handles.phase(1).(items{n}),handles.phase(3).(items{n}).weight,handles.us); if ~isempty(handles.phase(4).(items{n})) rm=rem(handles.phase(2).(items{n}).MN2(1),handles.us); rn=rem(handles.phase(2).(items{n}).MN2(2),handles.us); M=(handles.phase(2).(items{n}).MN2(1)-rm)./handles.us; N=(handles.phase(2).(items{n}).MN2(2)-rn)./handles.us; newregion=logical(zeros(M,N)); for q=1:handles.us for p=1:handles.us newregion=newregion|handles.phase(4).(items{n})... (p:handles.us:(p+(M-1).*handles.us),q:handles.us:(q+(N-1).*handles.us)); end end handles.phase(4).(items{n})=newregion; end handles.phase(2).(items{n}).MN2=size(handles.phase(1).(items{n})); handles.phase(2).(items{n}).dxy2=handles.phase(2).(items{n}).dxy2.*handles.us; end guidata(hObject,handles) prev_button_Callback(handles.prev_button, [], handles);